//
//  BaseNavigationController.swift
//  XingCeHelper
//
//  Created by 申铭 on 2022/10/14.
//

import UIKit

class BaseNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let appearance = UINavigationBarAppearance()
        appearance.backgroundColor = .systemBackground
        appearance.shadowColor = .clear
        navigationBar.standardAppearance = appearance
        navigationBar.scrollEdgeAppearance = appearance
        navigationBar.compactAppearance = appearance
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
//        viewController.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .done, target: nil, action: nil)
        
        if viewControllers.count > 0 {
            // 当前导航栏, 只有第一个viewController push的时候设置隐藏
            if viewControllers.count == 1 {
                viewController.hidesBottomBarWhenPushed = true
            }
        } else {
            viewController.hidesBottomBarWhenPushed = false
        }
        
        super.pushViewController(viewController, animated: animated)
    }

}
